import HTTP from '@/libs/http'

class Api extends HTTP {
  // 列表
  queryRecord({
    gridName,
    pointName,
    gridType,
    gridCode,
    name,
    startTime,
    endTime,
    inspectionResult,
    recordSize,
    pageSize
  }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/km/km_record_list',
      params: {
        gridName,
        pointName,
        gridType,
        gridCode,
        name,
        startTime,
        endTime,
        inspectionResult,
        recordSize,
        pageSize
      }
    })
  }

  // 网格列表
  list({ gridCode, date }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/km/km_inspection_list',
      params: {
        gridCode,
        date
      }
    })
  }

  // 查询网格
  grid({ gridType }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/km/km_grid_list',
      params: {
        gridType
      }
    })
  }

  // 开始巡查
  start({ gridCode }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/km/km_inspection_save',
      data: {
        gridCode
      }
    })
  }

  // 继续 暂停 结束
  changeStatus({ inspectionRecordCode, type }) {
    return this.request({
      method: 'PUT',
      url: '/smart/smart-app/km/km_inspection_update',
      data: {
        inspectionRecordCode,
        type
      }
    })
  }

  // 地图获取人员坐标
  getPeoplePoint({ longitude, latitude }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-government-statistic/supervise/surroundingGirdPerson',
      params: {
        longitude,
        latitude
      }
    })
  }

  // 巡查点详情
  detail({ code, date, gridCode }) {
    console.log('-----------------params', code)
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/km/km_record_detail',
      params: {
        code,
        date,
        gridCode
      }
    })
  }

  // 巡查点详情根据code
  handleDetailWithCode({ code, date }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/km/km_record_detail_code',
      params: {
        code,
        date
      }
    })
  }

  // 巡查点保存
  save(data) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/km/km_point_save',
      data
    })
  }
}

class CampusSecurityClass {
  constructor() {
    this.Api = new Api()
  }
}

const CampusSecurity = new CampusSecurityClass()

export default CampusSecurity
